using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.IO;
using System.IO.IsolatedStorage;


namespace TrovaIntruso.core
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class IconSet
    {
        public List<Icon> SpriteList { get; set; }
        public IconSet(string setname, ContentManager manager)
        {
            SpriteList = new List<Icon>();
            Load(setname, manager);
        }

        private void Load(string setname,ContentManager manager) {
            string old=setname;
            //Getting the number of icons to load
            setname = StaticOperation.BaseIconDir + "/" + setname;
            try
            {
                for (int i = 0; i < 25; i++)
                {
                    SpriteList.Add(new Icon(manager.Load<Texture2D>("Icone\\" + old + "\\" + old + " (" + (i + 1) + ")"), new Rectangle()));
                }
            }
            catch(Exception e) {
                string s = e.StackTrace.ToString();
            }
            Console.Write("");
        }

        public List<Icon> GetExactIcon() {
            List<Icon> tmplist = new List<Icon>();
            int i=0;
            int old=-1;
            while (i < 5)
            {
                int curr=StaticOperation.rand.Next(0,SpriteList.Count);
                if (curr != old)
                {
                    SpriteList[curr].InSet = true;
                    tmplist.Add(SpriteList[curr]);
                    i++;
                    old = curr;
                }
            }
            return tmplist;
        }

        
    }
}
